package com.zx.task.manager.enums;

import lombok.Getter;

/**
 * <p>
 * description: 任务状态枚举定义 <br>
 * create: 2025-10-13 20:15
 * </p>
 *
 * @author zhou  xun
 */
@Getter
public enum TaskStatusEnum {
    PENDING_RELEASE(1, "待发布"),
    PUBLISHED(2, "已发布"),
    IN_PROGRESS(3, "进行中"),
    COMPLETED(4, "已完成"),
    CLOSED(5, "已关闭"),
    CANCELLED(6, "已取消");

    /**
     * code
     */
    private final Integer code;
    /**
     * 说明
     */
    private final String desc;

    TaskStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static TaskStatusEnum getEnumByDesc(String desc) {
        for (TaskStatusEnum value : values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }

    public static TaskStatusEnum getEnumByCode(Integer code) {
        for (TaskStatusEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}